<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">新增</a>
     <!-- <a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="update()">修改</a> -->
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-pencil" plain="true" onclick="detail()">接口详情</a>
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">更改状态</a> 
</div>
<script type="text/javascript">
//查询回显
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:true,
        columns: [[
				  {field:'name', title:'通道名称', width:100}
	           	 ,{field:'shortName', title: '简称', width:100}
	           	 ,{field:'number', title: '接口数量', width:100}
	           	 ,{field:'state', title: '状态', width:100,
		        	 formatter : function(value, rowData,rowIndex) {  
	                     if(value==0){  
	                         return "启用";  
	                     }
	                       if(value==1){  
	                           return "禁用 ";  
	                     } 
	        		 }	 
	           	 }
		         ,{field:'createTime',title: '操作时间', width:116}
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});

//添加
/* function add() {
	top.openWindow("新增通道", getCurrUrl("add"), {size: '800x400'});
}  */
function add() {
	location.replace('add');
}

//修改
function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	location.replace('update?id='+id);
}

//接口详情
function detail(){
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var wayId = rowsSel[0].id;
	location.replace('detail?wayId='+wayId);
}

//删除
function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id= rowsSel[0].id;
	confirmMsg("确认更改吗？", function() {
		var id = rowsSel[0].id;
		var state = rowsSel[0].state;
		$.post("delete", {id: id,state:state}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("修改成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}
</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>